Skip to content

Apply Spice patches to DuckDB 1.5.2#14

Merged
sgrebnov merged 4 commits into
spiceai-1.5.2from
sgrebnov/spiceai-v1.5.2-patches
May 11, 2026
Merged

Apply Spice patches to DuckDB 1.5.2#14
sgrebnov merged 4 commits into
spiceai-1.5.2from
sgrebnov/spiceai-v1.5.2-patches

Conversation

@sgrebnov
Copy link
Copy Markdown

@sgrebnov sgrebnov commented May 11, 2026

🗣 Description

Build + the following tests were run to verify

 1. Composite key scan (commit 1) - verifies Index Scan is used + correct results
./build/debug/test/unittest "test/sql/index/art/scan/test_art_composite_key_scan.test"

# 2. View column binding with index (commit 1) - verifies index scan works through views
./build/debug/test/unittest "test/sql/index/art/issues/test_art_view_col_binding.test"

# 3. Arrow C API tests (commit 3) - verifies arrow scan correctness
./build/debug/test/unittest "[arrow][capi]"

# 4. All ART scan + issues tests (regression) - no regressions in index scans
./build/debug/test/unittest "test/sql/index/art/scan/*,test/sql/index/art/issues/*"
⚡ ./build/debug/test/unittest "test/sql/index/art/scan/test_art_composite_key_scan.test"
Filters: test/sql/index/art/scan/test_art_composite_key_scan.test
[1/1] (100%): test/sql/index/art/scan/test_art_composite_key_scan.test                                                      
===============================================================================
All tests passed (7 assertions in 1 test case)

⚡ ./build/debug/test/unittest "test/sql/index/art/issues/test_art_view_col_binding.test"
Filters: test/sql/index/art/issues/test_art_view_col_binding.test
[1/1] (100%): test/sql/index/art/issues/test_art_view_col_binding.test                                                      
===============================================================================
All tests passed (22 assertions in 1 test case)

⚡ ./build/debug/test/unittest "[arrow][capi]"
Filters: [arrow][capi]
[3/3] (100%): Test streaming arrow results in C API                                                                         
===============================================================================
All tests passed (103693 assertions in 3 test cases)

⚡ ./build/debug/test/unittest "test/sql/index/art/scan/*,test/sql/index/art/issues/*"
Filters: test/sql/index/art/scan/*,test/sql/index/art/issues/*
[25/25] (100%): test/sql/index/art/issues/test_art_fuzzer_persisted.test                                                    
============================================================================
All tests passed (1 skipped test, 363 assertions in 24 test cases)

Skipped tests for the following reasons:
require tpch: 1

🔨 Related Issues

🤔 Concerns

mach-kernel and others added 3 commits May 11, 2026 16:37
ART Index: Support compound key scans

Squashed commit of the following:

commit fec3602
Author: David Stancu <david@spice.ai>
Date:   Mon Nov 3 14:26:06 2025 -0500

    tryscanindex: fix direct match lookup, range check vec access

commit 2714c3d
Author: David Stancu <david@spice.ai>
Date:   Mon Nov 3 13:55:13 2025 -0500

    tryscanindex: do column matching first, to use possibly rebound matches in both sanity check and index expr rebinding
    add test for this scenario

commit 36ffa5b
Author: David Stancu <david@spice.ai>
Date:   Mon Nov 3 12:30:28 2025 -0500

    tryscanindex sanity check: indexed_columns / art column ids may not need remapping if the scan is not a view scan

commit 525f9c7
Author: David Stancu <david@spice.ai>
Date:   Thu Oct 30 10:42:17 2025 -0400

    do not do index scan if there are other non index filters in the predicate (fix shutdown_create_index.test)

commit b0a6e2d
Author: David Stancu <david@spice.ai>
Date:   Thu Oct 30 10:04:54 2025 -0400

    add test, bail out for eg composite query with IN () list

commit a22a430
Author: David Stancu <david@spice.ai>
Date:   Wed Oct 29 16:37:30 2025 -0400

    simplify filter expression storage index bindings (just reuse the ones we made earlier), fix single-ref-per-expr predicate to correctly walk expr tree and yank refs (allowing nesting in fns, etc)

commit 9c8c1ed
Author: David Stancu <david@spice.ai>
Date:   Wed Oct 29 15:11:23 2025 -0400

    copy index expressions before rewriting column refs

commit aff2c98
Author: David Stancu <david@spice.ai>
Date:   Wed Oct 29 14:36:33 2025 -0400

    table scan:

    rebind projected columns in ALL index exprs
    do not bail out early if more than one index expr
    hook up composite key scan

commit bfc6f02
Author: David Stancu <david@spice.ai>
Date:   Wed Oct 29 14:35:09 2025 -0400

    make specialized compound key scan state for eq compares, specialized scan using ARTKey::Concat
* make specialized compound key scan state for eq compares, specialized scan using ARTKey::Concat

* table scan:

rebind projected columns in ALL index exprs
do not bail out early if more than one index expr
hook up composite key scan

* copy index expressions before rewriting column refs

* simplify filter expression storage index bindings (just reuse the ones we made earlier), fix single-ref-per-expr predicate to correctly walk expr tree and yank refs (allowing nesting in fns, etc)

* add test, bail out for eg composite query with IN () list

* do not do index scan if there are other non index filters in the predicate (fix shutdown_create_index.test)

* tryscanindex sanity check: indexed_columns / art column ids may not need remapping if the scan is not a view scan

* tryscanindex: do column matching first, to use possibly rebound matches in both sanity check and index expr rebinding
add test for this scenario

* tryscanindex: fix direct match lookup, range check vec access

* compile on gcc
* via spec: get_schema has a lifetime that is owned by the caller, ergo if the caller wants to drop it, we should let them do that

* oops, still need to check for valid schema!
Copilot AI review requested due to automatic review settings May 11, 2026 13:41
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends DuckDB’s ART index scan pushdown logic to support composite (multi-column) ART indexes and to better handle scans through views with reordered projections, and adds regression tests for the reported issue (duckdb#17290). It also adjusts Arrow C API schema release handling in duckdb_arrow_scan.

Changes:

  • Add ART compound-key scan initialization and execution (TryInitializeCompoundKeyScan + CompoundKeyScan).
  • Update table scan index pushdown to attempt composite ART scans by mapping index expressions/filters to the current scan projection (including views).
  • Add SQL regression tests validating index scan usage for composite keys and view-based lookups.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
test/sql/index/art/scan/test_art_composite_key_scan.test New regression test asserting Index Scan is used for a 3-column composite ART equality predicate.
test/sql/index/art/issues/test_art_view_col_binding.test Extends view column-binding tests with an id index lookup through a view and checks plan uses Index Scan.
src/main/capi/arrow-c.cpp Changes schema handling in duckdb_arrow_scan by releasing the fetched schema immediately and removing prior release-function nullification logic.
src/include/duckdb/execution/index/art/art.hpp Declares new compound-key scan API in ART and adds required expression header include.
src/function/table/table_scan.cpp Implements composite-index pushdown by building per-key filter expressions and attempting compound scans when appropriate.
src/execution/index/art/art.cpp Implements compound-key scan state building and equality lookup using a concatenated ARTKey.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/function/table/table_scan.cpp Outdated
Comment thread src/execution/index/art/art.cpp
Comment thread src/function/table/table_scan.cpp
@sgrebnov sgrebnov changed the title Apply Spice patches for DuckDB 1.5.2 Apply Spice patches to DuckDB 1.5.2 May 11, 2026
rewrite_index_exprs was overwritten (not OR'd) per column match, so if
the last index column sat at position i==j the flag reset to false,
silently falling back to a sequential scan. Accumulate the flag instead.

Add regression test for partially reordered view projections.
Copilot AI review requested due to automatic review settings May 11, 2026 16:52
@sgrebnov sgrebnov force-pushed the sgrebnov/spiceai-v1.5.2-patches branch from a494daa to 9dac7ac Compare May 11, 2026 16:52
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 6 comments.

Comment thread src/function/table/table_scan.cpp
Comment thread src/function/table/table_scan.cpp
Comment thread src/include/duckdb/execution/index/art/art.hpp
Comment thread test/sql/index/art/scan/test_art_composite_key_scan.test
Comment thread src/execution/index/art/art.cpp
Comment thread test/sql/index/art/issues/test_art_view_col_binding.test
@sgrebnov
Copy link
Copy Markdown
Author

Unit and main integrations tests passed. There are some Regression tests failures the same as on 1.5.2 branch w/o Spice changes (flaky tests)
https://github.com/spiceai/duckdb/actions/runs/25684377092/job/75404072677

@sgrebnov sgrebnov merged commit 12ebe9c into spiceai-1.5.2 May 11, 2026
55 of 57 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants